<?php

if( !defined("IN_ELCIUS") ) exit;


class WowArmory{
	
	private static $urlBase;
	private static $initalized = false;
	private static $realm;
	
	public static $Data; // public data, write-only, untrustworthy scum
	
	public static function Initialize(){
		self::$initalized = true;
		self::$Data = array();
		
		self::$urlBase = 'http://us.battle.net/api/wow';
	}
	
	
	public static function Fetch( $type, $value, $realm, $fields ){
		// TODO: clean input?
		$return = array();
		
		$value = rawurlencode(utf8_encode($value));
		$realm = rawurlencode(utf8_encode($realm));
		// TODO: whitelist fields
		
		$return = json_decode(
			ExternalContent::Fetch(
				self::$urlBase."/${type}/${realm}/${value}?fields=".$fields,
				'{"lastModified":'
			),
			true
		);
		
		// fields=stats,talents,items,reputation,titles,professions,appearance,companions,mounts,achievements,progression,pvp,quests,pets,guild
		// http://us.battle.net/api/wow/character/frostmourne/elcius
		
		return $return;
		
	}
	
}

?>